import * as THREE from 'three'
import * as dat from 'dat.gui'
// 辅助方法
const createHelper = (scene: { add: (arg0: THREE.GridHelper, arg1: THREE.AxesHelper) => void; }) => {
    // 创建辅助坐标系
    const axesHelper = new THREE.AxesHelper()
    // 创建辅助平面
    const gridhelper = new THREE.GridHelper()
    scene.add(gridhelper, axesHelper);
}
// 自适应
const resizeHandler = (renderer: { setSize: (arg0: number, arg1: number) => void; },camera: { aspect: number; updateProjectionMatrix: () => void; }) => {
    window.addEventListener('resize', ()=>{
        // 更新相机
        camera.aspect =  document.body.clientWidth / document.body.clientHeight
        camera.updateProjectionMatrix() // 请注意，在大多数属性发生改变之后，你将需要调用.updateProjectionMatrix来使得这些改变生效
        // 更新渲染器大小
        renderer.setSize(document.body.clientWidth, document.body.clientHeight)
    })
}
// gui
const createGui = () => {
    return new dat.GUI()
}

export { createHelper, resizeHandler, THREE, createGui }